Question to "DOORSObj.runFile"

Hi!

I start a DXL-File with VBA from an excel-module with this code:

"DOORSObj.runFile ("D:\myTest.dxl")  'Runs DXL-Script in specific path; currently is a open DOORS-GUI needed"

If I start the code from the .dxl file directly in DXL-Interactions-Windows of the Doors-GUI, th DXL works fine!

If I start the exactly same code over this DOORSObj.runFile this code Fails, with this failure: "Parameter mit dem Wert null Object wurder der Argumentposition 1 übergeben. Ausführung gestoppt.

 

Here is the dxl-code from the dxl-file/interaction-window:

 

//pragma runLim, 1000

Module gmod_SSF = null;
Object gobj_SSF = current;
Object gobj_tmp = null;
string concatenatedAttributeLine = null;
string ident = null;
string statusHarmonisierung = null;
string objectHeading = null;
string objectText = null;
string typ = null;
string aenderungsStatus = null;
string aenderungsBemerkung = null;
int objectLevel = null;
string pathName = "D:\\myTest.txt";
bool bLoop = false;


if(canOpenFile(pathName, true) == true)
{
    Stream output = write(pathName);
    
    //Specifies the Doors-DB-path
    gmod_SSF = read("pathInDoors", true, true)
    
    
    //This while-loop jumps over the first chapter
    gobj_SSF = first(gobj_SSF);        //make sure, that the first line is pointed to
    gobj_SSF = next(gobj_SSF);        //go one object further
    while(level(gobj_SSF) > 1)
    {
        gobj_SSF = next(gobj_SSF);
        gobj_tmp = gobj_SSF;
    }
    
    
    //Debug
    //print identifier(gobj_SSF) "\n";
    //gobj_SSF = gobj_tmp
    //Debug
    //print identifier(gobj_SSF) "\n";
    
    
    
    //This for-loop iterates over alle objects and writes in specific .txt-file
    for gobj_SSF in gmod_SSF do
    {
        //Debug
        //print "for-loop" identifier(gobj_SSF) "\n";
        //gobj_SSF = gobj_tmp;
        //Debug
        //print "for-loop" identifier(gobj_SSF) "\n";
        
        if(bLoop && level(gobj_SSF) ==1)
        {
            break;
        }
        if(gobj_SSF == gobj_tmp)
        {
            bLoop = true;
        }
        
        if(!bLoop)
        {
            continue;
        }
        
        ident = identifier(gobj_SSF) "$$";
        statusHarmonisierung = gobj_SSF."Status Harmonisierung""" "$$";
        objectHeading = gobj_SSF."Object Heading""" "$$";
        objectText = gobj_SSF."Object Text""" "$$";
        typ = gobj_SSF."Typ""" "$$";
        aenderungsStatus = gobj_SSF."Änderungsstatus""" "$$";
        aenderungsBemerkung = gobj_SSF."Änderungsbemerkung""" "$$";
        objectLevel = level(gobj_SSF);
        
        concatenatedAttributeLine = "§§" ident statusHarmonisierung objectHeading objectText typ aenderungsStatus aenderungsBemerkung objectLevel"&&""\n\n\n";    //§§ = startsymbol, $$ = Trennung von Attributen, && = endsymbol
        output << concatenatedAttributeLine;    //Write output-String in .txt-file
    }
}
else
{
    //Error-Handling if file could not be opened
    print "File couldn't be opened!";
}

 

 

Can anyone say me, why doors on the first hand run the code and on the second hand the code don't run, while it is the same code??? Thx!


tobi_mehrl - Tue Dec 16 09:06:16 EST 2014

Re: Question to "DOORSObj.runFile"
Mathias Mamsch - Tue Dec 16 10:50:28 EST 2014

When you run over runFile, there is no "current" module. Therefore you will get a null object error. If you remember the first OLE example I gave you for accessing DOORS over COM, there I did:

Module m; 

for m in database do break;  // find the first open module

current = m; // set it as current 

Object o = current  // then you can get the current object

Of course, if you know the module it is easier to get a handle on it, and you can of course also add some safety checks, like  isvisible, so take the first open visible module. But accessing an interactive DOORS Session over COM always has pitfalls. In the end, latest if you open two DOORS instances, you will only be able to get data from the first one.

So it is always better to know, which module you want to access, and open it explicitly. Regards, Mathias